import { Component, ViewChild, OnInit } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar, Splashscreen } from 'ionic-native';
import { NavController } from 'ionic-angular';

import { TabsPage } from '../pages/tabs/tabs';
import { Storage } from '@ionic/storage';
import { LoginPage } from '../pages/account/login';

@Component({
  templateUrl: 'app.html'
})
export class MyApp implements OnInit {
  @ViewChild("appNav") nav: NavController;

  rootPage = TabsPage;
  _storage: Storage;
  constructor(platform: Platform, storage: Storage) {
    var that = this;
    that._storage = storage;
    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      StatusBar.styleDefault();
      Splashscreen.hide();
    });
  }
  ngOnInit() {
    var that = this;
    that._storage.get('loginToken').then((val) => {
      
      if (!val) {
        that.nav.push(LoginPage);
      }
    });
  }

}
